/*
* baseaicode13
*/
package com.kun.sun.baseaicode13.ctrl;

import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import java.util.List;
import java.util.HashMap;

import com.kun.sun.core.entity.BeanRet;
import com.kun.sun.core.entity.Page;
import com.kun.sun.core.tools.redis.RedisUtils;
import com.kun.sun.baseaicode13.entity.Baseaicode13;
import com.kun.sun.baseaicode13.service.Baseaicode13SV;

/**
*  控制器
*
* @author baseaicode13
*/
@RestController
@RequestMapping("/baseaicode13")
@Slf4j
@Api(value = "控制器", description = "控制器")
public class Baseaicode13Ctrl {

    @Resource
    protected RedisUtils redisUtils;

    @Resource
    private Baseaicode13SV baseaicode13SV;

    /**
    * 查询Baseaicode13一个详情信息
    * @param id 
    * @param code 
    * @return BeanRet
    */
    @ApiOperation(value = "查询Baseaicode13一个详情信息", notes = "查询Baseaicode13一个详情信息")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "",dataType = "java.lang.Long", paramType = "query"),
        @ApiImplicitParam(name = "code", value = "",dataType = "java.lang.Object", paramType = "query")
    })
    @GetMapping(value = "/load")
    @ResponseBody
    public Baseaicode13 load(java.lang.Long id,java.lang.Object code) {
        if(id==null){
        return null;
        }
        if(code==null){
        return null;
        }
        Baseaicode13 baseaicode13 = baseaicode13SV.load(id,code);
        log.info(JSON.toJSONString(baseaicode13));
        return baseaicode13;
    }


    /**
    * 根据条件id查询Baseaicode13一个详情信息
    *
    * @param id 
    * @return BeanRet
    */
    @ApiOperation(value = "查询Baseaicode13一个详情信息", notes = "查询Baseaicode13一个详情信息")
    @ApiImplicitParams({
       @ApiImplicitParam(name = "id", value = "",dataType = "java.lang.Long", paramType = "path")
    })
    @GetMapping(value = "/load/id/{id}")
    @ResponseBody
    public Baseaicode13 loadById(@PathVariable java.lang.Long id) {
        if(id==null){
           return null;
        }
        Baseaicode13 baseaicode13 = baseaicode13SV.loadById(id);
        log.info(JSON.toJSONString(baseaicode13));
        return baseaicode13;
    }
    /**
    * 根据条件code查询Baseaicode13一个详情信息
    *
    * @param code 
    * @return BeanRet
    */
    @ApiOperation(value = "查询Baseaicode13一个详情信息", notes = "查询Baseaicode13一个详情信息")
    @ApiImplicitParams({
       @ApiImplicitParam(name = "code", value = "",dataType = "java.lang.Object", paramType = "path")
    })
    @GetMapping(value = "/load/code/{code}")
    @ResponseBody
    public Baseaicode13 loadByCode(@PathVariable java.lang.Object code) {
        if(code==null){
           return null;
        }
        Baseaicode13 baseaicode13 = baseaicode13SV.loadByCode(code);
        log.info(JSON.toJSONString(baseaicode13));
        return baseaicode13;
    }


    /**
    * 查询Baseaicode13信息集合
    *
    * @return 分页对象
    */
    @ApiOperation(value = "查询Baseaicode13信息集合", notes = "查询Baseaicode13信息集合")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "curPage", value = "当前页", required = true, paramType = "query"),
    @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true, paramType = "query"),
    })
    @PostMapping(value = "/list")
    @ResponseBody
    public List<Baseaicode13> list(@RequestBody @ApiIgnore Baseaicode13 baseaicode13,Integer curPage,Integer pageSize) {
        Page<Baseaicode13> page=new Page<Baseaicode13>(pageSize,curPage);
        List<Baseaicode13> baseaicode13s = baseaicode13SV.list(baseaicode13,page.genRowStart(),page.getPageSize());
        int total = baseaicode13SV.count(baseaicode13);
        page.setTotalRow(total);
        log.info(JSON.toJSONString(page));
        return baseaicode13s;
    }


    /**
    * 查询Baseaicode13信息集合
    *
    * @return 分页对象
    */
    @ApiOperation(value = "查询Baseaicode13信息集合", notes = "查询Baseaicode13信息集合")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "curPage", value = "当前页", required = true, paramType = "query"),
    @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true, paramType = "query"),
    @ApiImplicitParam(name = "id", value = "", paramType = "query"),
    @ApiImplicitParam(name = "code", value = "", paramType = "query")
    })
    @GetMapping(value = "/list/by")
    @ResponseBody
    public List<Baseaicode13> listByPk(java.lang.Long id,java.lang.Object code,Integer curPage,Integer pageSize) {
        Page<Baseaicode13> page=new Page<Baseaicode13>(pageSize,curPage);
        List<Baseaicode13> baseaicode13s = baseaicode13SV.list(id,code, page.genRowStart(),page.getPageSize());
        int total = baseaicode13SV.count(id,code);
        page.setTotalRow(total);
        log.info(JSON.toJSONString(page));
        return baseaicode13s;
    }

    /**
    * 统计Baseaicode13信息数量根据主键
    *
    * @return 总条数
    */
    @ApiOperation(value = " 统计Baseaicode13信息数量根据主键", notes = " 统计Baseaicode13信息数量根据主键")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "id", value = "", paramType = "query"),
    @ApiImplicitParam(name = "code", value = "", paramType = "query")
    })
    @GetMapping(value = "/count/by")
    @ResponseBody
    public Integer count(java.lang.Long id,java.lang.Object code) {
        return baseaicode13SV.count(id,code);
    }

    /**
    * 统计Baseaicode13信息数量
    *
    * @return 总条数
    */
    @ApiOperation(value = "统计Baseaicode13信息数量", notes = "统计Baseaicode13信息数量")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "id", value = "", paramType = "query"),
    @ApiImplicitParam(name = "code", value = "", paramType = "query"),
    @ApiImplicitParam(name = "account", value = "", paramType = "query"),
    @ApiImplicitParam(name = "password", value = "", paramType = "query")
    })
    @PostMapping(value = "/count")
    @ResponseBody
    public Integer count(@RequestBody Baseaicode13 baseaicode13) {
        if(baseaicode13==null){
            return baseaicode13SV.count(new HashMap());
        }else{
            return baseaicode13SV.count(baseaicode13);
        }
    }



    /**
    * 创建Baseaicode13
    *
    * @return BeanRet
    */
    @ApiOperation(value = "创建Baseaicode13", notes = "创建Baseaicode13")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "account", value = "", paramType = "query"),
    @ApiImplicitParam(name = "password", value = "", paramType = "query")
    })
    @PostMapping("/build")
    @ResponseBody
    public Baseaicode13 build(@RequestBody @ApiIgnore Baseaicode13 baseaicode13) {
        baseaicode13SV.save(baseaicode13);
        return baseaicode13;
    }


    /**
    * 修改Baseaicode13
    *
    * @return BeanRet
    */
    @ApiOperation(value = "修改Baseaicode13", notes = "修改Baseaicode13")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "", paramType = "query"),
        @ApiImplicitParam(name = "code", value = "", paramType = "query"),
        @ApiImplicitParam(name = "account", value = "", paramType = "query"),
        @ApiImplicitParam(name = "password", value = "", paramType = "query")
    })
    @PutMapping("/modify")
    @ResponseBody
    public Baseaicode13 modify(@ApiIgnore Baseaicode13 baseaicode13) {
        baseaicode13SV.modify(baseaicode13);
        return baseaicode13;
    }

    /**
    * 删除Baseaicode13
    *
    * @return BeanRet
    */
    @ApiOperation(value = "删除Baseaicode13", notes = "删除Baseaicode13")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "", paramType = "query"),
        @ApiImplicitParam(name = "code", value = "", paramType = "query")
    })
    @DeleteMapping("/delete")
    @ResponseBody
    public BeanRet delete(java.lang.Long id,java.lang.Object code) {
        baseaicode13SV.delete(id,code);
        return BeanRet.create(true, "删除Baseaicode13成功");
    }

}
